package controllers;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import models.beans.User;
import persistence.UserDAO;

@ManagedBean
@RequestScoped
public class UserController {
	private User user;
	private UserDAO dao;
	
	public UserController() {
		user = new User();
		dao = new UserDAO();
	}
	
	public String cadastrarConta(){
		String retorno = "erro";
		
		if(dao.cadastrarUsuario(user)) retorno = "sucesso";
		
		
		return retorno;
	}
	
	public int getIdConta(){
		return dao.getId(user);
	}

	//Getters and Setters
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public UserDAO getDao() {
		return dao;
	}

	public void setDao(UserDAO dao) {
		this.dao = dao;
	}
	
}
